package com;

import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.List;

public class InsertListCar {
    public static void main(String[] args) {

        MyBatisSqlSessionFactory factory = new MyBatisSqlSessionFactory();
        SqlSession sqlSession = factory.getMyBatisSqlSessionFactory().openSession();

        TestDao testDao = sqlSession.getMapper(TestDao.class);
        System.out.println(testDao);

        //插入多行数据
        Car car = new Car();
        car.setName("大众");
        car.setPrivce(9000.0f);

        Car car2 = new Car();
        car2.setName("大众");
        car2.setPrivce(9000.0f);
        List<Car> carList = new ArrayList<Car>();
        carList.add(car);
        carList.add(car2);

        int id = testDao.getInsertListCar(carList);
        sqlSession.commit();
        System.out.println(id);
    }
}
